//Set your settings
function download(strFileURL,strHDLocation)
{
	//strFileURL = "http://www.domain.com/file.zip"
	//strHDLocation = "D:\file.zip"

	// Fetch the file

	var objXMLHTTP = new ActiveXObject("MSXML2.XMLHTTP");

	document.write(strFileURL)
	objXMLHTTP.open("GET", strFileURL, false);

	objXMLHTTP.send();
	
	if(objXMLHTTP.Status == 200){
		var objADOStream = new ActiveXObject("ADODB.Stream");
		objADOStream.Open();
		objADOStream.Type = 1;// 'adTypeBinary

		objADOStream.Write(objXMLHTTP.ResponseBody);
		objADOStream.Position = 0;//    'Set the stream position to the start

		var objFSO = new ActiveXObject("Scripting.FileSystemObject");
		if(objFSO.FileExists(strHDLocation))
			objFSO.DeleteFile(strHDLocation);
		
		objFSO = null;

		objADOStream.SaveToFile(strHDLocation);
		objADOStream.Close();
		objADOStream = null;
	}
	objXMLHTTP = null;

}

function download2(strURL,strHDLocation)
{
    /*try
    {*/
        // Create the WinHTTPRequest ActiveX Object.
        var WinHttpReq = new ActiveXObject(
                                  "WinHttp.WinHttpRequest.5.1");
        
		WinHttpReq.SetProxy( 2, 
                     "10.1.107.222:8080", 
                     "localhost");
		
		WinHttpReq.SetTimeouts(0,0,0,300000);
		
        //  Create an HTTP request.
        var temp = WinHttpReq.Open("GET", strURL, false);

        //  Send the HTTP request.
        WinHttpReq.Send();
        
        //  Retrieve the response text.
        var stream = new ActiveXObject("ADODB.Stream");
		stream.Open();
		stream.Type = 1;
		
		stream.Write(WinHttpReq.ResponseBody);
		stream.Position = 0;
		stream.SaveToFile(strHDLocation);
		stream.Close();
		stream=null;
    /*}
    catch (objError)
    {
        var strResult = objError + "\n"
        strResult += "WinHTTP returned error: " + 
            (objError.number & 0xFFFF).toString() + "\n\n";
        strResult += objError.description;
		alert(strResult)
    }*/
}